/* utilities.vala
 *
 * Copyright (C) 2010, 2011  Richard Talbot-Watkins
 * Copyright (C) 2010, 2011  Dave Jeffery
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Authors:
 *  Richard Talbot-Watkins <richtw1@gmail.com>
 * 	Dave Jeffery <david.richard.jeffery@gmail.com>
 */

namespace MonsterDesigner {

	/**
	 * Error domain for file import and parsing operations.
	 */
	private errordomain IOError {
		FILE_NOT_MONSTER_SPRITES,
		ILLEGAL_COLOUR,
		ICON_NOT_FOUND
	}

	/**
	 * Error domain for the CircularStack used for undo and redo.
	 */
	private errordomain StackError {
		STACK_EMPTY
	}

	/**
	 * Class to keep clones of the sprite data array in.
	 *
	 * A hack, as Generics are still unfinished in Vala. I'd have preferred to 
	 * simply use uint8[], as in the C#.
	 *
	 * @param data Intended to keep copies of the sprite data bitmap array.
	 */
	private class Clone {
		public uint8[] data;

		public Clone (uint8[] data) { 
			this.data = data;
		}
	}

	/**
	 * Struct to hold a Cairo RGB value.
	 *
	 * In Cairo, RGB values are held as floating point numbers in the range
	 * 0.0 to 1.0 instead of the more usual 0 to 255.
	 */
	private struct CairoColour {
		public double red;
		public double green;
		public double blue;

		/**
		 * Constructor function.
		 *
		 * @param
		 */
		public CairoColour(double red, double green, double blue) {
			this.red = red;
			this.green = green;
			this.blue = blue;
		}
	}

	/**
	 * Struct to hold a point.
	 *
	 * Although it looks like a class, it's passed by value not reference.
	 */
	private struct Point {
		public int x;
		public int y;

		public Point (int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	/**
	 * Struct to hold a rectangle.
	 *
	 * Although it looks like a class, it's passed by value not reference.
	 */
	private struct Rectangle {
		public int x;
		public int y;
		public int width;
		public int height;

		public Rectangle (int x, int y, int width, int height) {
			this.x = x;
			this.y = y;
			this.width = width;
			this.height = height;
		}
	}

	/**
	 * List of possible toolbox editing modes. 
	 * 
	 * The modes are simply ints from 0 - 5.
	 */
	private enum Mode {
		DRAW,
		FILL,
		INSERT_ROW,
		DELETE_ROW,
		SELECT,
		PASTE
	}

	/**
	 * Gdk.EventExpose mouse buttons codes.
	 *
	 * There are more, but we're just interested in these two.
	 */
	private enum MouseButton {
		LEFT = 1,
		RIGHT = 3
	}

	/**
	 * Drag and Drop target code. 
	 *
	 * Monster Designer is only interested in receving URI's passed in from
	 * drag and drops from Nautilus.
	 */
	private enum Target {
		URI
	}

	/* Drag and Drop acceptable source objects. */
	private const Gtk.TargetEntry[] targets = {	
		{ "text/uri-list", 0, Target.URI } 
	};

	/* Drag and drop destination flags. */
	private const Gtk.DestDefaults destination_flags = Gtk.DestDefaults.ALL;

	/* If a file is dropped onto the window, we want to copy its URI. */
	private Gdk.DragAction actions = Gdk.DragAction.COPY;	
}
